home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / SourceCode / AdobeExamples / NX_Binary / iinterpreterhooks.m < prev    next >
Encoding:
Text File  |  1992-12-19  |  3.2 KB  |  153 lines

  1.  
  2. /*
  3.  * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
  4.  *
  5.  * (b)  If this Sample Code is distributed as part of the Display PostScript
  6.  *    System Software Development Kit from Adobe Systems Incorporated,
  7.  *    then this copy is designated as Development Software and its use is
  8.  *    subject to the terms of the License Agreement attached to such Kit.
  9.  *
  10.  * (c)  If this Sample Code is distributed independently, then the following
  11.  *    terms apply:
  12.  *
  13.  * (d)  This file may be freely copied and redistributed as long as:
  14.  *    1) Parts (a), (d), (e) and (f) continue to be included in the file,
  15.  *    2) If the file has been modified in any way, a notice of such
  16.  *      modification is conspicuously indicated.
  17.  *
  18.  * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
  19.  *    Adobe Systems Incorporated.
  20.  * 
  21.  * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
  22.  *    CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
  23.  *    AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
  24.  *    ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
  25.  *    OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
  26.  *    WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
  27.  *    WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
  28.  *    DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
  29.  *    FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
  30.  *    OF THIRD PARTY RIGHTS.
  31.  */
  32.  
  33. /*
  34. *    iinterpreterhooks.m
  35.  *
  36.  *    Version:    2.0
  37.  *    Author:    Ken Fromm
  38.  *    History:
  39.  *            03-07-91        Added this comment.
  40. */
  41.  
  42. #import "Graphic.h"
  43. #import "FormatApp.h"
  44. #import <objc/List.h>
  45.  
  46. extern void     initGparms();
  47.  
  48. static UPath    *uPath;
  49. static GParms  gParms;
  50. static id        currentList;
  51.  
  52. void ii_resetPathStruct()
  53. {
  54.     uPath->num_pts = 0;
  55.     uPath->num_ops = 0;
  56. }
  57.  
  58. void ii_initPathStruct()
  59. {
  60.     uPath = [NXApp  getUpathBuffer];
  61.     ii_resetPathStruct();
  62.     currentList = NULL;
  63. }
  64.  
  65. void ii_initGraphicStruct()
  66. {
  67.     initGparms(&gParms);
  68. }
  69.  
  70. void ii_setgray(float  aval)
  71. {
  72.     gParms.gray = aval;
  73.     gParms.color_type = GRAY;
  74. }
  75.  
  76. void ii_setlinewidth(float  aval)
  77. {
  78.     gParms.linewidth = aval;
  79. }
  80.  
  81. void ii_setlinejoin(int  aval)
  82. {
  83.     gParms.linejoin = (unsigned char) aval;
  84. }
  85.  
  86. void ii_setdash()
  87. {
  88.     /* setdash not implemented */
  89. }
  90.  
  91. void ii_setmiterlimit(float  aval)
  92. {
  93.     gParms.miterlimit = aval;
  94. }
  95.  
  96. void ii_setlinecap(int  aval)
  97. {
  98.     gParms.linecap = (unsigned char) aval;
  99. }
  100.  
  101. void ii_setrgbcolor(float  r, float g, float b)
  102. {
  103.     gParms.red = r;
  104.     gParms.green = g;
  105.     gParms.blue = b;
  106.     gParms.color_type = RGB;
  107. }
  108.  
  109. void ii_insertPathCoord(NXPoint *aPt, int num_pts, char dps_op, NXPoint *currentpoint)
  110. {
  111.     int    i;
  112.  
  113.     for (i = 0;  i < num_pts; i++, aPt++)
  114.     {
  115.         uPath->pts[uPath->num_pts++] = aPt->x;
  116.         uPath->pts[uPath->num_pts++] = aPt->y;
  117.     }
  118.  
  119.     uPath->ops[uPath->num_ops++] = dps_op;        
  120. }
  121.  
  122. void ii_insertPath(int  path_type, NXRect *bounds)
  123. {
  124.     id        aGraphic;
  125.  
  126.     NXRect    bbox;
  127.  
  128.     if (uPath->num_ops > 0)
  129.     {
  130.         bbox = *bounds;
  131.         if (path_type == STROKE)
  132.             NXInsetRect(&bbox, -gParms.linewidth/2, -gParms.linewidth/2);
  133.  
  134.         aGraphic = [Graphic new];
  135.         gParms.path_type = (unsigned char) path_type;
  136.         [aGraphic  installGparms:&gParms];
  137.         [aGraphic  installUpath:uPath  andBounds:&bbox];
  138.  
  139.         if (!currentList)
  140.             currentList = [List new];
  141.  
  142.         [currentList  addObject:aGraphic];
  143.     }
  144. }
  145.  
  146. void ii_insertPage(int  page)
  147. {    
  148.     [[NXApp getDrawingView]  insertList:currentList];
  149.  
  150.     currentList = NULL;
  151. }
  152.  
  153.